<?php 
	
	include($_SERVER['DOCUMENT_ROOT']."/eventos/sistema/common/login/seguranca.php"); // Inclui o arquivo com o sistema de segurança
	include($_SERVER['DOCUMENT_ROOT']."/eventos/sistema/common/paginacao.php");
	
	protegePagina(); // Chama a função que protege a página
	if(!isset($_SESSION)) { 
 	 SESSION_START();
	}
	
	$idEvento	=	$_GET["idEvento"];	
	
	 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="/eventos/css/Cliente/Layout.css" />

<script type="text/javascript" src="/eventos/js/participante/jquery-1.7.2.js"></script>
<script type="text/javascript" src="/eventos/js/funcoes.js"></script>
<script language="javascript" src="/eventos/js/ajax.js"></script> 
<script language="javascript" src="/eventos/js/instrucao.js"></script>

<script language="javascript">
	function classificarCandidato(idDiv,numDiv, acao){
		
		var div = document.getElementById(idDiv + numDiv);
		var ps	= document.getElementById("ps" + numDiv);
		var s	= document.getElementById("s" + numDiv);
		var d	= document.getElementById("d" + numDiv);
		
		
		if(acao == 'ps'){
			if(ps.checked){
				div.style.backgroundColor	= "#09F";		
				div.style.display 			= "block";				
			}
			else{
				div.style.display 			= "none";
			}
			s.checked					= false;
			d.checked					= false;	
			
		}
		if(acao == 's'){
			if(s.checked){
			div.style.display 			= "block";
			div.style.backgroundColor	= "#3C0";
			}
			else{
				div.style.display 			= "none";
			}
			ps.checked					= false;
			d.checked					= false;
		}
		if(acao == 'd'){
			if(d.checked){
			div.style.backgroundColor	= "#FF5959";		
			div.style.display 			= "block";
			}
			else{
				div.style.display 			= "none";
			}
			s.checked					= false;
			ps.checked					= false;
		}	
	
	}
	
	function qualificarCandidato(idEvento, idUsuario, idEmpresa, acao, div, numDiv){
		
		var ps		= document.getElementById("ps" + numDiv);
		var s		= document.getElementById("s" + numDiv);
		var d		= document.getElementById("d" + numDiv);
		var bolMarcado = '0';
		
		if(acao == 'ps'){
			if(ps.checked){bolMarcado = '1';}
			else{bolMarcado = '0';}				
		}
		if(acao == 's'){
			if(s.checked){bolMarcado = "1";}
			else{bolMarcado = "0";}	
		}
		if(acao == 'd'){
			if(d.checked){bolMarcado = "1";}
			else{bolMarcado = "0";}	
		}	
		 
	
	
		abrirPag("actSelecionaCandidato.php?idEvento=" + idEvento + "&idUsuario=" + idUsuario + "&acao=" + acao + "&bolMarcado=" + bolMarcado + "&operacao=alterar"  ,"dvCandidatosSelecionados");
	}
	
	abrirPag('actSelecionaCandidato.php?idEvento=' + '<?php echo $idEvento ?>','dvCandidatosSelecionados')

</script>


<title>Untitled Document</title>
</head>

<body>
<br />
<div id="dvCandidatosSelecionados" class="dvCandidatosSelecionados"></div>

<div style="border:solid 1px; border-color:#CCCCCC; border-top:none;border-right:none;width:800px;height:800px;margin-left:350px; border-bottom:none">


	<?php 
                    //Consulta no banco de dados
                        $galeria = "SELECT F.*, DP.strNome, CE.idEvento, CE.idSituacao 
                                    FROM tblfoto F,
										 tbldadospessoais DP,
										 tblcandidatoevento CE
									WHERE F.idUsuario  = DP.idUsuario
									AND	  F.idUsuario  = CE.idUsuario
									AND   CE.idEvento  = $idEvento
									ORDER BY F.idUsuario, F.bolPrincipal DESC ";
									 
                        $galeria = mysql_query($galeria) or die("Erro no SQL: ".mysql_error());
                    ?>
    
                    
                    <br /><br />
                    <br />
					 <?php 
                       $cont = 0;
					   $contUsuario = 1;
					   $zindex 			= 0;
					   $marginLeft 		= "";
					   $marginTop  		= "";
					   $marginTopDesc   = "";
                       while ($array_galeria = mysql_fetch_array($galeria)) {   		 
                            $cont = $cont + 1;
                     		$idUsuarioAtual = $array_galeria[idUsuario];
							//deixar flexivel para parametrização com 9 fotos
							
							
							if($cont > 1 && $idUsuarioAtual != $idUsuarioAnterior){
								$contUsuario	=	$contUsuario + 1;
								
								$cont = 1;
							}
							
							$zindex = 6 - $cont;
							
							if($contUsuario <= 4){
								$marginTop 		= "35px";
								$marginTopDesc	= "240px";
							 }
							 else if($contUsuario > 4 && $contUsuario <= 8){
							 	$marginTop 		= "350px";
								$marginTopDesc	= "555px";
							 }
							 else if($contUsuario > 8 && $contUsuario <= 12){
							 	$marginTop = "600px";
							 }
									if($contUsuario == 1 || $contUsuario == 5 || $contUsuario == 9){
										$marginLeft = "10px";
										
									}
									else if ($contUsuario == 2 || $contUsuario == 6){
										$marginLeft = "210px";	
									}
									else if ($contUsuario == 3 || $contUsuario == 7){
										$marginLeft = "410px";	
									}
									else {
										$marginLeft = "610px";	
									}
								
							?>		
									<?php if($cont == 1){?>
                                    <div class="dvMarcacaoFotosCliente" id="dvMarcacaoFotosCliente<?php echo $contUsuario;?>" style="margin-top:<?php echo $marginTop?>;margin-left:<?php echo $marginLeft?>;"></div>
									<script language="javascript">
								
										startClassificarCandidato('<?php echo $array_galeria[idSituacao]; ?>','dvMarcacaoFotosCliente<?php echo $contUsuario;?>');
									
										function startClassificarCandidato(idSituacao, div){
											var div = document.getElementById(div);
											if(idSituacao == 1){
													div.style.backgroundColor	= "#09F";		
													div.style.display 			= "block";
											}
											if(idSituacao == 2){
												
												div.style.display 			= "block";
												div.style.backgroundColor	= "#3C0";
											}
											if(idSituacao == 3){
												div.style.backgroundColor	= "#FF5959";		
												div.style.display 			= "block";
											}
											
										}
										
									</script>

									
									<?php }?>
                                    
                                    
                                    <div class="dvFotosCliente" style="margin-top:<?php echo $marginTop?>;margin-left:<?php echo $marginLeft?>; position:absolute;z-index:<?php echo $zindex?>">	
										<a class="linkFotos" rel="lytebox[fotosPessoais] slb_group[<?php echo $array_galeria[idUsuario] ?>] slb" href="galeria/uploads/<?php echo $array_galeria[idUsuario]. "/" .$array_galeria[strCaminho];?>">
                                        	<?php if($cont == 1){ ?>
                                            	<img src="/eventos/uploads/<?php echo $array_galeria[idUsuario]. "/" .$array_galeria[strCaminho];?>" width="150" height="200" />
                                        	<?php } ?>
                                        </a>				
									</div>
                                    
									<?php if($cont == 1){?>
                                    <div style="margin-top:<?php echo $marginTopDesc;?>;margin-left:<?php echo $marginLeft?>; position:absolute;width:170px;z-index:1000;text-align:center">
                                    	<table width="100%" border="0" align="center">
                                        <tr>
                                        	<td> <?php echo $array_galeria[strNome]?></td>
                                        </tr>
                                    	</table>
                                        <hr />
                                        <table width="100%" border="0" cellpadding="0" cellspacing="0">
                                        <tr align="center">
                                        	<td width="24"><input type="checkbox" id="ps<?php echo $contUsuario;?>" <?php if($array_galeria[idSituacao] == 1){?> checked="checked" <?php }?>  name="ps<?php echo $contUsuario;?>" onclick="classificarCandidato('dvMarcacaoFotosCliente',<?php echo $contUsuario;?>,'ps');qualificarCandidato('<?php echo $array_galeria[idEvento] ?>', '<?php echo $array_galeria[idUsuario] ?>', '000000001', 'ps', 'dvCandidatosSelecionados', '<?php echo $contUsuario?>');" /> </td>
                                            <td width="110">Pré selecionar </td>
                                        </tr>
                                        <tr align="center">
                                        	<td><input type="checkbox" id="s<?php echo $contUsuario;?>" name="s<?php echo $contUsuario;?>" <?php if($array_galeria[idSituacao] == 2){?> checked="checked" <?php }?> onclick="classificarCandidato('dvMarcacaoFotosCliente',<?php echo $contUsuario;?>,'s');qualificarCandidato('<?php echo $array_galeria[idEvento] ?>', '<?php echo $array_galeria[idUsuario] ?>', '000000001', 's', 'dvCandidatosSelecionados', '<?php echo $contUsuario?>');" /> </td>
                                            <td>Selecionar </td>
                                        </tr>
                                        <tr align="center">
                                        	<td><input type="checkbox" id="d<?php echo $contUsuario;?>"  name="d<?php echo $contUsuario;?>" <?php if($array_galeria[idSituacao] == 3){?> checked="checked" <?php }?> onclick="classificarCandidato('dvMarcacaoFotosCliente',<?php echo $contUsuario;?>,'d');qualificarCandidato('<?php echo $array_galeria[idEvento] ?>', '<?php echo $array_galeria[idUsuario] ?>', '000000001', 'd', 'dvCandidatosSelecionados', '<?php echo $contUsuario?>');" /> </td>
                                            <td>Descartar </td>
                                        </tr>
                                    	</table>
                                    </div>
                                    
                                    <?php }?>
								
					<?php 
							
							$idUsuarioAnterior = $array_galeria[idUsuario]; 
						} 
					?>
                    
       						
</div>

<div id="teste" style="width:100px;border:solid 1px;">
tete4
</div>


</body>
</html>